cmake_minimum_required(VERSION 3.8)
project(ipa_coverage_planning_plugin)

if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    add_compile_options(-Wall -Wextra -Wpedantic)
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(std_msgs REQUIRED)
find_package(geometry_msgs REQUIRED)
find_package(visualization_msgs REQUIRED)
find_package(nav_msgs REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(nav2_core REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(pluginlib REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(OpenCV REQUIRED)
find_package(ipa_building_msgs REQUIRED)

set(ipa_building_navigation_LIBRARIES       $ENV{HOME}/ros2_ws/install/ipa_building_navigation/lib/libipa_building_navigation.so)
set(libipa_room_exploration_LIBRARIES       $ENV{HOME}/ros2_ws/install/ipa_room_exploration/lib/libipa_room_exploration.so)
set(libmap_accessibility_analysis_LIBRARIES $ENV{HOME}/ros2_ws/install/ipa_room_exploration/lib/liblibmap_accessibility_analysis.so)

include_directories(
        include
        ${OpenCV_INCLUDE}
)

set(library_name ${PROJECT_NAME})

set(dependencies
        rclcpp
        rclcpp_action
        rclcpp_lifecycle
        std_msgs
        visualization_msgs
        nav2_util
        nav2_msgs
        nav_msgs
        geometry_msgs
        builtin_interfaces
        tf2_ros
        nav2_costmap_2d
        nav2_core
        pluginlib
        ipa_building_msgs
        )


add_library(${library_name} SHARED
        src/ipa_coverage_planning_plugin.cpp
        )
target_link_libraries(${library_name}
        ${OpenCV_LIBRARIES}
        ${ipa_building_navigation_LIBRARIES}
        ${libipa_room_exploration_LIBRARIES}
        ${libmap_accessibility_analysis_LIBRARIES}
        )
ament_target_dependencies(${library_name} ${dependencies})
target_compile_definitions(${library_name} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS")
pluginlib_export_plugin_description_file(nav2_core ipa_coverage_planning_plugin.xml)

install(TARGETS ${library_name}
        ARCHIVE DESTINATION lib
        LIBRARY DESTINATION lib
        RUNTIME DESTINATION lib/${PROJECT_NAME}
        )

install(DIRECTORY include/
        DESTINATION include/
        )

install(FILES ipa_coverage_planning_plugin.xml
        DESTINATION share/${PROJECT_NAME}
        )

ament_package()
